package com.cjb.cloudmonitor.controller;

import com.cjb.cloudmonitor.entity.*;
import com.cjb.common.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 服务器监控
 * @Author chenjinbin
 * @Package IntelliJ IDEA
 * @Class MonitorServerController
 * @Date 2023-09-27 23:57
 */
@RestController
@RequestMapping("monitor/server")
public class MonitorServerController {

    /**
     * 日志
     */
    private final static Logger log = LoggerFactory.getLogger(MonitorServerController.class);
    /**
     * 服务器相关信息
     */
    @GetMapping("info")
    @Operation(summary = "所有信息")
    public Result<Server> getServerInfo() {
        Server server = new Server();
        return Result.success(server);
    }

    /**
     * CPU相关信息
     */
    @GetMapping("cpu")
    @Operation(summary = "cpu信息")
    public Result<Cpu> getCpuInfo() {
        Cpu cpu = new Cpu();
        return Result.success(cpu);
    }

    /**
     * 内存相关信息
     */
    @GetMapping("mem")
    @Operation(summary = "内存相关信息")
    public Result<Mem> getMemInfo() {
        Mem mem = new Mem();
        return Result.success(mem);
    }

    /**
     * JVM相关信息
     */
    @Operation(summary = "jvm相关信息")
    @GetMapping("jvm")
    public Result<Jvm> getJvmInfo() {
        Jvm jvm = new Jvm();
        return Result.success(jvm);
    }

    /**
     * 系统相关信息
     */
    @GetMapping("sys")
    @Operation(summary = "系统相关信息")
    public Result<Sys> getSysInfo() {
        Sys sys = new Sys();
        return Result.success(sys);
    }

    /**
     * 系统文件相关信息
     */
    @GetMapping("disk")
    @Operation(summary = "系统文件相关信息")
    public Result<List<Disk>> getSysFileInfo() {
        Server server = new Server(new Disk());
        return Result.success(server.getDisks());
    }

}
